/**
 * @ClassName LC233
 * @Author ykx
 * @Date 2024/3/29 22:52
 * @Version 1.0
 */
public class LC233 {
    public static void main(String[] args) {
        LC233 lc233 = new LC233();
        System.out.println(lc233.countDigitOne(808182));
    }

    public int countDigitOne(int n) {
        int result = 0;
        for (int i = 0; i <= n; i++) {
            String s = i + "";
            if (s.contains("1")) {
                result += s.length() - s.replace("1", "").length();
            }
        }
        return result;
    }
}
